#!/usr/bin/env python

import sys
import Tkinter as tk
from libtovid.guis.helpers import SetChapters
from os import path

if len(sys.argv) < 2:
    print("Usage: set_chapters.py video")
    exit()

video = sys.argv[1]
if not path.exists(video):
    print('Error: %s does not exist' %video)
    exit()

def print_chapters():
    if app.get_chapters():
        sys.stdout.write(app.get_chapters() + '\n')

root = tk.Tk()
app = SetChapters(root, '-menu', 'Mplayer', print_chapters, style='standalone')
app.run(video)
app.pack()

root.mainloop()

